﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Threading;
using System.Threading.Tasks;

namespace ArgusPCLib.IO
{
	public abstract class StreamWrapper : Stream
	{
		public StreamWrapper(Stream baseStream)
		{
			if (baseStream == null)
				throw new ArgumentNullException("baseStream");
			this.BaseStream = baseStream;
		}

		#region Properties
		public Stream BaseStream { get; private set; }
		public override bool CanRead { get { return this.BaseStream.CanRead; } }
		public override bool CanSeek { get { return this.BaseStream.CanSeek; } }
		public override bool CanTimeout { get { return this.BaseStream.CanTimeout; } }
		public override bool CanWrite { get { return this.BaseStream.CanWrite; } }
		public override long Length { get { return this.BaseStream.Length; } }
		public override long Position
		{
			get { return this.BaseStream.Position; }
			set { this.BaseStream.Position = value; }
		}
		public override int ReadTimeout
		{
			get { return this.BaseStream.ReadTimeout; }
			set { this.BaseStream.ReadTimeout = value; }
		}
		public override int WriteTimeout
		{
			get { return this.BaseStream.WriteTimeout; }
			set { this.BaseStream.WriteTimeout = value; }
		}
		#endregion

		#region Methods
		public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
		{
			return this.BaseStream.ReadAsync(buffer, offset, count, cancellationToken);
		}

		public override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken)
		{
			return this.BaseStream.CopyToAsync(destination, bufferSize, cancellationToken);
		}

		public override Task FlushAsync(CancellationToken cancellationToken)
		{
			return this.BaseStream.FlushAsync(cancellationToken);
		}

		public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
		{
			return this.BaseStream.WriteAsync(buffer, offset, count, cancellationToken);
		}

		protected override void Dispose(bool disposing)
		{
			if (disposing == true)
				this.BaseStream.Dispose();
			base.Dispose(disposing);
		}

		public override void Flush()
		{
			this.BaseStream.Flush();
		}

		public override int Read(byte[] buffer, int offset, int count)
		{
			return this.BaseStream.Read(buffer, offset, count);
		}

		public override int ReadByte()
		{
			return this.BaseStream.ReadByte();
		}

		public override long Seek(long offset, SeekOrigin origin)
		{
			return this.BaseStream.Seek(offset, origin);
		}

		public override void SetLength(long value)
		{
			this.BaseStream.SetLength(value);
		}

		public override void Write(byte[] buffer, int offset, int count)
		{
			this.BaseStream.Write(buffer, offset, count);
		}

		public override void WriteByte(byte value)
		{
			this.BaseStream.WriteByte(value);
		}
		#endregion
	}
}
